<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
<meta name="format-detection" content="telephone=no, email=no" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<!--控制条块状黑色-->
<meta content="telephone=no" name="format-detection" />
<!--禁止数字转拨号-->
<link rel="stylesheet" type="text/css" href="../../css/reset.css">
<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/second.css" />
<script src="../../js/jquery-1.11.3.min.js"></script>
</head>

<body>
	<!--内容区-->
	<div class="mui-content ">
		<div class="show-bg">
			<div class="show-btn">
				<a href="">在线演示</a>
			</div>
			<!-- mui-action-back -->
			<div class="return-btn ">
				<a>返回</a>
			</div>
		</div>

	</div>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/mui.view.js"></script>
	<script src="../../js/loading.js"></script>
	<script src="../../js/globalvar.js" type="text/javascript"
		charset="utf-8"></script>
	<script>
		var floor = '';
		var door = '';
		var speed = '';
		var power = '';
		var run_status = '';
		var lift_status = '';
		var yxcs = '';
		var kmcs = '';
		//定义方法取到电梯的数据
		function getHxzRun() {
			return "floor=" + floor + ";door=" + door + ";speed=" + speed
					+ ";power=" + power + ";run_status=" + run_status
					+ ";lift_status=" + lift_status + ";yxcs=" + yxcs
					+ ";kmcs=" + kmcs;
		}
		$(function() {
			mui.init()
			var timer = window.setInterval(setinterval, 1000); //启动定时器
			mui.ready(function() {
				//加载框
				mui.showLoading("正在加载..", ".warn-list");
				Request2();
				/* 
				//监控详情  原生页面
				mui('.show-btn').on('tap', 'a', function () {
				  //获取视频播放条件
				  $(this).attr('href', gethxzinfo());
				  console.log(getHxzRun());
				}) */
				mui('.return-btn').on('tap', 'a', function() {
					localStorage.removeItem('verifycode');
					window.history.go(-2);
					// mui.openWindow({
					//     url: 'year-lift-detail.html',
					// })

				})
			});
			//ajax 请求 黑匣子ID
			function Request2() {
				var gzurl = 'http://123.56.47.206/lift/hxz5.jsp?req=gethxzinfo&zcdm=3010-640302-201108-2062';
				$.ajax(gzurl, {
					dataType : 'json', //服务器返回json格式数据
					timeout : 20000, //超时时间
					async : true, //true异步加载
					success : function(data) {
						if (data.code == 2001) {
							// 返回值处理
							var ref = data.data;
							if (ref.length != 0) {
								var dthxzid = ref[0].dthxzid; // 黑匣子ID
								var verifycode = ref[0].verifycode; // 视频观看code
								var deviceserial = ref[0].deviceserial;
								var accesstoken = ref[0].accesstoken;
								var appkey = ref[0].appkey;
								var lng = ref[0].lng;
								var lat = ref[0].lat;
								var vhref = 'dt:req=video;at=' + accesstoken
										+ ';deviceSerial=' + deviceserial
										+ ';verifyCode=' + verifycode
										+ ';appkey=' + appkey + ';hxzid='
										+ dthxzid;
								$('.show-btn a').attr('href', vhref);// 得到就设置
								mui('.show-btn').on('tap', 'a', function() {
									// 获取视频播放条件
									window.location.href = this.href;
								})

								//隐藏加载框
								mui.hideLoading(function() { //隐藏后的回调函数  
								});
							} else {
								/* mui('.show-btn').on('tap', 'a', function() {
									alert("演示摄像头不在线,请稍后在试");
								}) */

								//隐藏加载框
								mui.hideLoading(function() { //隐藏后的回调函数  
								});
							}

						} else if (data.code == 2002) {
							/* alert('登录异常，请您重新登录');
							mui.openWindow({
								url : '../../login.html',
								id : 'login.html'
							}) */
						} else {
							/* console.log(data);
							mui.openWindow({
								url : '../../404.html',
								id : '404.html'
							}) */
						}
					},
					error : function(xhr, type, errorThrown) { //异常处理； console.log(type);
						/* alert('登录异常，请您重新登录');
						mui.openWindow({
							url : '../../login.html',
							id : 'login.html'
						})
						console.log(data); */
					}
				});
			}
			//电梯数据定时器
			function setinterval() {
				var gzurl = 'http://123.56.47.206/lift/hxz5.jsp?req=gethxzrun&hxzid=142847807';
				$.ajax(gzurl, {
					dataType : 'json', //服务器返回json格式数据
					timeout : 20000, //超时时间
					async : true, //true异步加载
					success : function(data) {
						if (data.code == 2001) {
							//返回值处理
							var ref = data.data;
							if (ref != 0) {
								floor = ref[0].floor;
								door = ref[0].door;
								speed = ref[0].speed;
								power = ref[0].power;
								run_status = ref[0].run_status;
								lift_status = ref[0].lift_status;
								kmcs = ref[0].kmcs;
								yxcs = ref[0].yxcs;
								//console.log('这是hxz实时信息'+floor);
							} else {
								//$('.monitor_det').fadeOut();
								mui.alert('黑匣子不存在或者不在线');
								clearInterval(timer);
							}

						} else if (data.code == 2002) {
							/* alert('登录异常，请您重新登录');
							mui.openWindow({
								url : '../../login.html',
								id : 'login.html'
							}) */
						} else {
							/* mui.openWindow({
								url : '../../404.html',
								id : '404.html'
							}) */
						}
					},
					error : function(xhr, type, errorThrown) { //异常处理； console.log(type);
						/* mui.openWindow({
							url : '../../404.html',
							id : '404.html'
						}) */
					}
				});
			}

			// 视频播放需要数据
			function gethxzinfo() {
				var at = localStorage.getItem('accesstoken');
				var deviceSerial = localStorage.getItem('deviceSerial');
				var verifyCode = localStorage.getItem('verifycode');
				var hxzid = localStorage.getItem('dthxzid');
				var appkey = localStorage.getItem('appkey');
				return "dt:req=video;at=" + at + ";deviceSerial="
						+ deviceSerial + ";verifyCode=" + verifyCode
						+ ";appkey=" + appkey + ";hxzid=" + hxzid;
			}

		})
	</script>
</body>

</html>